import java.io.File;

public class Demo5 {

    private static void scan(File currentDir){
        //1.先判断对象是否为目录
        if(!currentDir.isDirectory()){
            return;
        }
        File[] files=currentDir.listFiles();
        if(files==null||files.length==0){
            return;
        }
        System.out.println(currentDir.getAbsolutePath());
        for(File f:files){
            if(f.isFile()){
                System.out.println(f.getAbsolutePath());
            }
            else{
                scan(f);
            }
        }
    }

    public static void main(String[] args) {
        File file=new File("./");
        scan(file);
    }
}
